package leetcode.t1Array;

/**
 * @author K
 * @date 2024/1/23 13:38
 */
public class T11_MaxArea {


    /**
     * 11. 盛最多水的容器
     * 双指针，每次移动最矮的木板，期望计算出最大值
     *
     * @param height
     * @return
     */
    public static int maxArea(int[] height) {
        int l = 0, r = height.length - 1;
        int result = 0;
        while (l < r) {
            if (height[l] < height[r]) {
                result = Math.max(result, height[l] * (r - l));
                l++;
            } else {
                result = Math.max(result, height[r] * (r - l));
                r--;
            }
        }

        return result;
    }


    public static void main(String[] args) {
        int i = maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7});
        System.out.println();
    }

}
